package com.rover.system.service;

import org.activiti.engine.IdentityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.rover.system.dao.BaseDao;
import com.rover.system.entity.User;

@Service("userRoleService")
@Transactional
public class UserRoleService {

	@Autowired
	private BaseDao dao;
	@Autowired
	private	IdentityService identityService;
	@Transactional
	public void deleteRoles(User user) {
//		Query q = userRoleDao.getCurrentSession().createQuery(
//				"delete from UserRole where tuser=:tuser");
//		q.setParameter("tuser", user);
//		q.executeUpdate();
		
		//同步删除Activiti
//		  List<UserRole> liUserRole=dao.findHql("from UserRole ur where ur.tuser.id="+user.getId().toString(), null);
//		  for (UserRole userRole : liUserRole) {
//	               identityService.deleteMembership(user.getId().toString(), userRole.getTrole().getId().toString());
//	            }
//		Map<String, Object> params = new HashMap<String, Object>();
//		params.put("tuser", user);
//        dao.executeHql("delete from UserRole where tuser=:tuser", params);
	}
}
